{% extends 'admin/common/base.html' %}
{% block css %}
{{super()}}
<link href="{{url_for('admin.static',filename='ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css')}}" rel="stylesheet"/>
{% endblock %}
{% block body %}
<body class="hold-transition box box-main">
	<input id="id"   name="id"    type="hidden" value="{{id}}"/>
	<input id="treeName" name="treeName"  type="hidden" value="{{d.name}}"/>
    <input id="dictType" type="hidden" value="{{d.dict_type}}"/>
	<div class="wrapper"><div class="treeShowHideButton" onclick="$.tree.toggleSearch();">
		<label id="btnShow" title="显示搜索" style="display:none;">︾</label>
		<label id="btnHide" title="隐藏搜索">︽</label>
	</div>
	<div class="treeSearchInput" id="search">
		<label for="keyword">关键字：</label><input type="text" class="empty" id="keyword" maxlength="50">
		<button class="btn" id="btn" onclick="$.tree.searchNode()"> 搜索 </button>
	</div>
	<div class="treeExpandCollapse">
		<a href="#" onclick="$.tree.expand()">展开</a> /
		<a href="#" onclick="$.tree.collapse()">折叠</a>
	</div>
	<div id="tree" class="ztree treeselect"></div>
	</div>
    <a id="scroll-up" href="#" class="btn btn-sm display"><i class="fa fa-angle-double-up"></i></a>
</body>
{% endblock %}
{% block js %}
{{ super() }}
<script src="{{url_for('admin.static',filename='ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js')}}"></script>
<script>
    $(function() {
        var url = "{{url_for('admin.sys.gencode.tree_data')}}";
        var options = {
            url: url,
            expandLevel: 1,
            onClick : zOnClick,
            data: {
                key: {
                    title: "title",
                    url: '',
                    dict_type: 'dict_type'
                },
                simpleData: {
                    enable: true,
                    pIdKey: "parent_id",
                    
                }
            }
        };
        $.tree.init(options);
    });
    
    function zOnClick(event, treeId, treeNode) {
        var treeId = treeNode.id;
        var treeName = treeNode.name;
        $("#treeId").val(treeId);
        $("#treeName").val(treeName);
        $("#dictType").val(treeNode.dict_type)
    }
</script>
{% endblock %}
